# src/schemas/sys_entity_i18n.py
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime


# ---------------- 基础字段 ----------------
class SysEntityI18nBase(BaseModel):
    # api_id: Optional[str] = Field(None, max_length=36, description="API主键，用于关联其他系统")
    entity_type: str = Field(..., max_length=30, description="对象类型：objects / object_field / object_field_rule / menu / dict / process")
    entity_id: str = Field(..., max_length=36, description="对应实体主键")
    language: str = Field(..., max_length=10, description="语言标识：zh-CN / en-US / fr-FR ...")
    entity_value: str = Field(..., max_length=500, description="翻译后的文本")
    description: Optional[str] = Field(None, max_length=500, description="翻译备注/上下文提示")
    enabled: bool = Field(True, description="是否启用该条翻译")
    deletion_mark: bool = Field(False, description="删除标志")
    deletion_reason: Optional[str] = Field(None, max_length=255)
    deletion_date: Optional[datetime] = None
    deletion_by: Optional[str] = Field(None, max_length=255)
    create_date: Optional[datetime] = None
    creator_by: Optional[str] = Field(None, max_length=255)
    last_updated_date: Optional[datetime] = None
    last_updated_by: Optional[str] = Field(None, max_length=255)


# ---------------- 创建/更新 ----------------
class SysEntityI18nCreate(SysEntityI18nBase):
    api_id: Optional[str] = Field(None, max_length=36, description="API主键，用于关联其他系统")


# ---------------- 响应 ----------------
class SysEntityI18n(SysEntityI18nBase):
    id: str
    api_id: Optional[str] = Field(None, max_length=36, description="API主键，用于关联其他系统")

    class Config:
        from_attributes = True  # ORM 兼容
